﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace SX.Utils
{
    public  static partial class CommonHelper
    {
        public static int GetPageIndex() {
            return CommonHelper.ToInt(HttpContext.Current.Request["page"], 1);
        }

        public static int GetPageRows()
        {
            return CommonHelper.ToInt(HttpContext.Current.Request["rows"], 20);
        }

        public static string GetSort(string defaultSort) {
            string sort =   HttpContext.Current.Request["sort"];
            if (sort.IsNullOrEmpty())
            {
                return defaultSort;
            }
            string order = HttpContext.Current.Request["order"];
            if (order.IsNullOrEmpty())
            {
                order = "asc";
            }
            return sort + " " + order;
        }
        public static string GetSort4Mg(string defaultSort)
        {
            string sort = HttpContext.Current.Request["sort"];
            if (sort.IsNullOrEmpty())
            {
                return defaultSort;
            }
            string order = HttpContext.Current.Request["order"];
            if (order.IsNullOrEmpty())
            {
                order = "asc";
            }
            return sort + ":" + (order=="asc"?"1":"-1");
        }
    }
}
